<?php
namespace admin\action;

use herosphp\bean\Beans;
use herosphp\http\HttpRequest;


/**
 * 行情趋势action
 * @author yu
 */
class QuoteTrendAction extends CommonAction
{

    protected $serviceBean = 'quote.data.service';

    public function index(HttpRequest $request)
    {

        $searchArr['brand_name'] = $request->getParameter('brand_name', 'urldecode');

        $searchArr['addtime_s'] = $request->getParameter('addtime_s');

        $searchArr['addtime_e'] = $request->getParameter('addtime_e');

        $quoteDataService = Beans::get('quote.data.service');

        $result = $quoteDataService->getList(1000, 1, $searchArr);

        if ($searchArr['addtime_s']) {

            $addtime_s = date('Y-m-d', strtotime($searchArr['addtime_s']));
        } else {

            $addtime_s = date('Y-m-d',strtotime('-7 day'));
        }

        if ($searchArr['addtime_e']) {

            $addtime_e = date('Y-m-d', strtotime($searchArr['addtime_e']));
        } else {

            $addtime_e = myDate();
        }

        $trendChartData = $quoteDataService->getChartData($result['items'], $addtime_s, $addtime_e);

        $this->assign('trendItems', $result['items']);

        $this->assign('trendChartData', $trendChartData);

        $this->assign('breadcrumb', array('行情管理', '行情趋势'));

        $this->setView('quoteTrend/index');

    }




}
